/**
 *
 * @author spider
 */
package br.unb.plugins.geral.Action;

import java.awt.event.ActionEvent;
import java.util.HashMap;

import br.unb.plugins.geral.view.XmlFrame;
import br.unb.plugins.geral.view.XmlComboBox;
import br.unb.utils.Console;

public class XmlComboBoxAction extends XmlFrameAction {

    String comboName = "xmlComboName";

    public XmlComboBoxAction() {
        this("xmlComboName");
    }

    public XmlComboBoxAction(String alias) {
        super(alias);
        comboName = alias;
    }

    public void actionPerformed(ActionEvent arg0) {

        HashMap components = homeFrame.getComponentsMap();
        //TODO ensure that the correct combo is returned from the statement below
        Object obj = components.get(comboName);
        if (obj instanceof XmlComboBox) {
            XmlComboBox combo = (XmlComboBox) obj;
            XmlFrame frame = combo.getFrame();
            //TODO review setParameter here
            homeFrame.getGenModel().setParameter(comboName, frame.getGenModel());
        } else {
            Console.println(
                    "Combo box "
                    + comboName
                    + " not found on the frame "
                    + homeFrame.getName(), System.err);
        }
    }
}
